home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
tlx_sq21.zip
/
MEGAMAIL.SLT
< prev
next >
Wrap
Text File
|
1992-03-20
|
11KB
|
343 lines
//-----------------------------------------------------------
// MEGAMAIL.SL? Telix script to fetch mail from a PCBoard BBS.
//
// This script is normally called from the script PCB.SLC.
//
// Please look at the comments through the whole file, and modify to
// suit your needs, BEFORE you use it. Then recompile with CS MEGAMAIL.
//-----------------------------------------------------------
// If you have suggestions for improving this script, please suggest
// improvements to me via old-fashioned snail-mail to:
// Author: Inge Vabekk
// Hamangskogen 108
// N-1300 SANDVIKA
// NORWAY
// tel. (472) 546 396
str myprot [2] // My protocol
,codename [10] // BBS codename.
,help [80] // Help line.
,runstr [80] // DSZ runstring (if used).
// Script and global names:
,global []="GLOBAL" // Global script.
,Cprot []="CPROT" // Current protocol.
,prompt []="PROMPT" // Current command prompt.
,Cname []="CNAME" // Codename of current BBS.
,mdir []="MDIR" // Mail directory.
,dsz []="DSZ" // Code for DSZ (if in use).
;
int tol = 300 // No activity for 30 sec.
,tmark // makes script time out.
,stat
,BBSver // PCB version
;
//-----------------------------------------------------------
// MEGAmail script is entered here.
//-----------------------------------------------------------
main()
{
int c, i, j // For tracking:
,un // Upload Now
,dn // Download Now
,rt // Return.
,pd // Back to ProDoor.
,W; // Still working...
entry(); // Updates status bar.
read (cprot,myprot) ; // Get current BBS protocol.
un = track ("Upload Your",0); // Wait for message.
pd = track ("Prodoor",1); // Prodoor again.
W = track ("se wait ...",0); // Returning.
tmark = timer_start (tol); // Give me a minute.
while ((stat=trig()) > 0) // answer any questions.
{ if (stat == un)
break; // Upload Now?
goto done; // Door aborted.
}
release();
if (!carrier()) goto done; // Fail?
waitfor ("^J",1); // Wait for linefeed.
terminal();
for (w=gety(); w>=0; --w) // Get the "Upload your" line.
{ vgetchrs(0,w,help,0,80);
if ((j=strposi (help,".UL",0)) > 0)// Packet name in this line?
break;
}
if (w <= 0)
{ megabort();
goto done;
}
for (i=--j; i > 0; --i) // Find first character.
{ if (subchr(help,i) == ' ') break;
}
substr (help,++i,j-i,codename); // Move it down.
write (cname,codename); // Save BBS ID-code.
// Start sending the mail packet.
// See if we can find the upload file.
// ----------------------------------------------------------
help = _up_dir; // Get upload directory.
i = strlen(help)-1;
if (subchr(help,i)!='\') // Append "\" if
strcat (help,"\"); // necessary.
strcat (help,codename); // Copy codename to filename.
strcat (help,".UL"); // Add extension.
prints ("");
printsc ("T²: Filename: ");
prints (help);
if (filesize(help) <= 0) // No file to send?
{ megabort(help);
goto done;
}
send_file(); // Send the mail file.
// Define new strings for tracking.
//-----------------------------------------------------------
dn = track ("gin Your",0); // Download now.
rt = track ("system..",0); // Return to system.
W = track ("rking On",0); // Still working....
tmark = timer_start (tol); // Give me a minute.
while ((stat=trig()) > 0) // answer any questions.
{ if (stat == rt) // Return to system?
goto abort;
else if (stat == dn) // Download now?
break;
else if (stat == W) // Still working?
; // Just wait....
}
release(); // Free all tracks and timer.
get_file();
if (carrier()) goto done;
abort:
release();
failtone();
return (-1);
done:
release();
goodtone();
return (0);
}
//-----------------------------------------------------------
// Send upload mail file.
//-----------------------------------------------------------
send_file()
{
int c;
if (read (dsz,runstr) > 0) // DSZ?
{ strcat (runstr,help); // Add filename to runstring.
while ((c=strchr(runstr,0,'\')) > 0)
setchr (runstr,c,'/'); // Replace '\' by '/'.
exec (dsz,runstr); // Use DSZ.
flushbuf(); // Flush input buffer.
}
else
send (subchr(myprot,0),help); // Send file.
}
//-----------------------------------------------------------
// Get download mail file.
//-----------------------------------------------------------
get_file()
{
int save;
save = _zmod_auto; // Save auto zmodem indicator.
_zmod_auto = 0;
if (read (dsz,runstr) < 0) // DSZ not defined:
{ help = _down_dir; // Save download dir.
read (mdir,_down_dir); // and change it.
receive (subchr(myprot,0),"");
_down_dir = help; // Restore download dir.
}
else
{ newdir (_down_dir); // DSZ: Change directory.
strcat (runstr," r"); // Add parameters: Receive.
strlower (myprot); // Protocol.
strcat (runstr,myprot);
strcat (runstr," -y"); // OK to overwrite.
exec (dsz,runstr); // Use DSZ.
flushbuf(); // Flush input buffer.
newdir (_telix_dir); // Go back to TELIX directory!
}
_zmod_auto = save; // restore auto zmodem indicator.
_down_dir = help; // Restore download dir.
//read (prompt,help); // Get command prompt.
//waitfor (help,20); // Wait for next command.
}
//----------------------------------------------------------
// Abort Megamail door.
//-----------------------------------------------------------
megabort(str help)
{
int i, t1;
for (i=0; i<3; ++i) // Three short beeps.
{ tone (2400,6);
delay(1);
}
mess ("T²: File missing:");
mess (help);
mess ("No upload mail - Attempting to abort MegaMail door");
t1 = track (" Command",0); // Command
track (" wait ..",0); // Please wait...
track ("Prodoor",1); // Prodoor again.
i=0;
tmark = timer_start (tol); // Give me thirty seconds.
do
{ cputs ("^X"); // Send Control-X.
delay (2); // as long as we're online.
if ((stat=track_hit(0))) // If trigger,
timer_restart (tmark,tol); // reset timer.
if (stat==t1) // If command, count to
{ if (++i > 2) break; // three to remove CNTL-X-es
cputs ("^M"); // from his input buffer.
}
} while (!time_up(tmark) && carrier());
return; // Return.
}
//-----------------------------------------------------------
// Routine to update colors and status bar.
//-----------------------------------------------------------
entry ()
{
_back_color = 1;
_fore_color = 14;
update_term();
}
//---------------------------